<?php

set_time_limit(0);
error_reporting(E_ALL);
ini_set('display_errors', '0');

define('DS'         , DIRECTORY_SEPARATOR);
define('ENV'        , 'prod');
define('ROOT_DIR'   , __DIR__ . DS . '..' . DS);
//define('ENV', 'dev');

require_once ROOT_DIR . 'Shared' . DS . 'Application.php';

$App = Shared\Application::getInstance();
$App->setEnvironment(ENV);
$App->cacheClear();

try {
    $App->run();
    $html     = $App->getFrontController()->getHtml();
    $Response = new Symfony\Component\HttpFoundation\Response($html);
    $Response->send();
} catch (\Shared\Exceptions\NotFoundException $Ex) {
    $App->createException($Ex, 404);
} catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $Ex) {
    $App->createException($Ex, 404);
} catch (\Shared\LRC\LanguageNotFoundException $Ex) {
    $App->createException($Ex, 404);
} catch (\Exception $Ex) {
    $App->createException($Ex, 500);
}

exit();
